package 题目集.二分;

import java.util.Scanner;

public class demo01炼金 {
    static int n;
    static int maxN = (int) (1e4 + 10), maxV = (int) 1e9;
    static int[][] logs;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        logs = new int[n][2];
        for (int[] log : logs) {
            log[0] = sc.nextInt();
            log[1] = sc.nextInt();
        }
        System.out.print(findMin(1, maxV) + " ");
        System.out.println(findMax(1, maxV));
    }

    public static int findMax(int l, int r) {
        while (l <= r) {
            int m = l + r >> 1;
            if (check(m) >= 0) {
                l = m + 1;
            } else {
                r = m - 1;
            }
        }
        if (check(l) == 0) {
            return l;
        }
        return r;
    }

    public static int findMin(int l, int r) {
        while (l <= r) {
            int m = l + r >> 1;
            if (check(m) > 0) {
                l = m + 1;
            } else {
                r = m - 1;
            }
        }
        if (r > 0 && check(r) == 0) {
            return r;
        }
        return l;
    }

    public static int check(int v) {
        int cur = 0;
        for (int[] log : logs) {
            cur = log[0] / v;
            if (cur != log[1]) return cur - log[1];
        }
        return 0;
    }
}
